package com.ruoyi.xuexiao.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.xuexiao.domain.entity.BasicRegion;
import com.ruoyi.xuexiao.domain.param.AuditingParam;
import com.ruoyi.xuexiao.domain.param.RwTzV3VParam;
import com.ruoyi.xuexiao.domain.param.SuperviseParam;
import com.ruoyi.xuexiao.service.AuditingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 审核统计
 * @author 田江余
 * @date: 2024-5-27 19:45:41
 */
@Api(tags = "审核统计模块")
@RestController
@RequestMapping("/auditingSel")
public class AuditingController {

    @Autowired
    private AuditingService auditingService;

    /**
     * 审核统计  上/下半年矿业权数，已审核，未审核，审核百分比
     * @author 田江余
     * @param rwTzV3DTO
     * @return
     */
    @ApiOperation("审核统计  上/下半年矿业权数，已审核，未审核，审核百分比")
    @GetMapping("/selectRwTzV")
    public R<Map<String,Object>> selectRwTzV(RwTzV3VParam rwTzV3DTO) {
        return R.ok(auditingService.selectRwTzVYear(rwTzV3DTO));
    }

    /**
     * 上/下半年省级核查任务进度
     * @author 田江余
     * @param rwTzV3DTO
     */
    @ApiOperation("上/下半年省级核查任务进度")
    @GetMapping("/InTheFirstYearThe")
    public R<List<RwTzV3VParam>> InTheFirstYearThe(RwTzV3VParam rwTzV3DTO) {
        return R.ok(auditingService.InTheFirstHalfOfTh(rwTzV3DTO));
    }

    /**
     * 上/下半年市级核查任务进度
     * @author 田江余
     * @param rwTzV3DTOS
     */
    @ApiOperation("上/下半年市级核查任务进度")
    @GetMapping("/InTheSecondHalfOfYear")
    public R<List<RwTzV3VParam>> InTheSecondHalfOfYear(ArrayList<RwTzV3VParam> rwTzV3DTOS, SuperviseParam supervise) {
        return R.ok(auditingService.inTheSecondHalfOfYear(rwTzV3DTOS,supervise));
    }

    /**
     * 上/下半年县级核查任务进度
     * @author 田江余
     */
    @ApiOperation("上/下半年县级核查任务进度")
    @GetMapping("/InTheSecondOf")
    public R<List<BasicRegion>> InTheSecondOf(SuperviseParam supervise) {
        return R.ok(auditingService .inTheSecondHalf(supervise));
    }

    /**
     * 审核统计导出
     * @author 田江余
     */
    @ApiOperation("审核统计导出")
    @PostMapping("/exportExtractAuditingSel")
    public void exportExtractData(HttpServletResponse response, @RequestBody List<AuditingParam> rwTzV3DTOS) throws UnsupportedEncodingException {
        //设置请求体
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("审核统计数据.xlsx", "UTF-8"));
        ExcelUtil<AuditingParam> util = new ExcelUtil<>(AuditingParam.class);
        util.exportExcel(response, rwTzV3DTOS, "审核统计");
    }
}